let loadingPos = []
let successPos = []

self.onmessage = (e) => {
  const { height, zoom } = e.data;
  // console.log('height->,zoom->', height, zoom);
  loadingPos.push(height)
  const params = {
    "service": "WFS",
    "version": "1.0.0",
    "request": "GetFeature",
    "typeName": "mianyang:mianyang_poi",
    "outputFormat": "application/json",
    "cql_filter": `minzoom=${zoom}`
  }
  const url = `http://183.234.52.92:6081/geoserver/mianyang/ows?${new URLSearchParams(params)}`
  // console.log('url->', url);
  sendRequest(url)
};

// 发送geoserver请求
function sendRequest (url) {
  const xhr = new XMLHttpRequest();
  xhr.responseType = 'json';
  xhr.open('GET', url, true);
  xhr.onreadystatechange = function () {
    console.log('xhr->', xhr.responseText);
    if (xhr.readyState === 4) {
      if (xhr.status === 200) {
        console.log('请求成功', xhr.responseText);
        const processedData = processData(xhr.responseText);
        successPos.push(processedData)
      }
    }
  }
}

function processData (data) {
  return data;
}